package com.yimi.yinhepda.base;

import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.alibaba.fastjson.JSONObject;
import com.baidu.mobstat.StatService;
import com.uce.pda.activity.ArriveActivity;
import com.uce.pda.activity.CenterJobActivity;
import com.uce.pda.activity.DespatchScanActivity;
import com.uce.pda.activity.ExpressMailTrailActivity;
import com.uce.pda.activity.FitActivity;
import com.uce.pda.activity.JobActivity;
import com.uce.pda.activity.LookingForActivity;
import com.uce.pda.activity.MisTakeQueryActivity;
import com.uce.pda.activity.MisTakeTypeListActivity;
import com.uce.pda.activity.OneKeyActivity;
import com.uce.pda.activity.PickupScanActivity;
import com.uce.pda.activity.RealNameRegistrationActivity;
import com.uce.pda.activity.RetreatItemScanActivity;
import com.uce.pda.activity.SafeCheckActivity;
import com.uce.pda.activity.ScanActivity;
import com.uce.pda.activity.ScanArriveToSendActivity;
import com.uce.pda.activity.ScanBackFlowActivity;
import com.uce.pda.activity.ScanMailerActivity;
import com.uce.pda.activity.ScanReceiverToSendActivity;
import com.uce.pda.activity.StockSendActivity;
import com.uce.pda.activity.StoreHouseActivity;
import com.uce.pda.activity.UploadStatisticsActivity;
import com.uce.pda.activity.WareHousingScanActivity;
import com.uce.pda.util.ScanOpenUtils;
import com.uce.pda.util.UIActivity;
import com.uce.pda.util.down_util;
import com.yimi.yinhepda.MainActivity;
import com.yimi.yinhepda.R;
import com.yimi.yinhepda.callbacks.OnClickCallBack;
import com.pda.ym.callbacks.UICallBack;
import com.yimi.yinhepda.db.table.FuncBtnTable;
import com.yimi.yinhepda.entity.bean.CurrentSpaceEntity;
import com.yimi.yinhepda.net.QueryPlaceNetRequest;
import com.yimi.yinhepda.utils.Common;
import com.pda.uce.commom.util.LoadUtils;
import com.pda.ym.utils.SharedPreferUtil;
import com.yimi.yinhepda.utils.ToastUtil;
import com.yimi.yinhepda.views.check_balance.CheckBalanceActivity;
import com.yimi.yinhepda.views.createPackage_module.CreatePackageMangerActivity;
import com.yimi.yinhepda.views.createPackage_module.CreatePackageOperatorActivity;
import com.yimi.yinhepda.views.createPackage_module.ReleasePackageOperatorActivity;
import com.yimi.yinhepda.views.dispatch_module.DispatchBackScanActivity;
import com.yimi.yinhepda.views.dispatch_module.DispatchTaskActivity;
import com.yimi.yinhepda.views.exceptionsUpload_module.ExceptionUploadActivity;
import com.yimi.yinhepda.views.exceptionsUpload_module.ProblemBillUploadActivity;
import com.yimi.yinhepda.views.exceptionsUpload_module.WithoutTitleBillActivity;
import com.yimi.yinhepda.views.fenbo_ziti.FenBoZiTiActivity;
import com.yimi.yinhepda.views.kua_yue_spotGoods.KuaYueTaskActivity;
import com.yimi.yinhepda.views.lan_huo_scan.LanHuoScanActivity;
import com.yimi.yinhepda.views.load_module.LoadUnloadGroupActivity;
import com.yimi.yinhepda.views.moveStock_module.MoveStockActivity;
import com.yimi.yinhepda.views.sign_manager.SelectBreakCardTypeActivity;
import com.yimi.yinhepda.views.sort_module.SortingActivity;
import com.yimi.yinhepda.views.stockCheck_module.CheckTaskActivity;
import com.yimi.yinhepda.views.stockCheck_module.CheckTaskCreateActivity;
import com.yimi.yinhepda.views.stockCheck_module.DifferReportActivity;
import com.yimi.yinhepda.views.stockCheck_module.StockInLocalDeptActivity;
import com.yimi.yinhepda.views.unload_module.CreateUnloadTaskActivity;
import com.yimi.yinhepda.views.unload_module.palletbind.ForkliftUnBindActivity;
import com.yimi.yinhepda.views.unload_module.palletbind.SingleUnBindActivity;

import java.util.List;

import butterknife.ButterKnife;

public abstract class BaseFragment extends Fragment {

    protected SharedPreferUtil sharedPreferUtil = SharedPreferUtil.getInstance();

    public abstract String getPageName();

    /**
     * 当前窗的viewId
     */
    public abstract int getContentViewId();

    protected void onClickBtn(View v) {
        Common.specificSetting(getContext());
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = View.inflate(getContext(), getContentViewId(), null);
        ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void onResume() {
        super.onResume();
        StatService.onPageStart(getContext(), getPageName());
    }

    @Override
    public void onPause() {
        super.onPause();
        StatService.onPageEnd(getContext(), getPageName());
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        ButterKnife.unbind(this);
    }

    public void toActivity(Class mClass) {
        Intent intent = new Intent(getContext(), mClass);
        startActivity(intent);
    }

    protected void goToActivity(FuncBtnTable item) {
        if (item.getNameCode().equals(Common.FUNC_CJPD)) {
            //创建盘点单
            toActivity(CheckTaskCreateActivity.class);
        } else if (item.getNameCode().equals(Common.FUNC_FCJC)) {
            //复称检查
            if (sharedPreferUtil.getOfflineMode()) {
                ToastUtil.showToast(getString(R.string.no_use_in_offline));
                return;
            }
            //复秤检查
            Intent intent = new Intent(getContext(), CheckBalanceActivity.class);
            Bundle bundle = new Bundle();
            bundle.putSerializable("iService", MainActivity.iService);
            intent.putExtras(bundle);
            startActivity(intent);
        } else if (item.getNameCode().equals(Common.FUNC_CCFJ)) {
            //叉车分拣
            toActivity(ForkliftUnBindActivity.class);
        } else if (item.getNameCode().equals(Common.FUNC_PSRW)) {
            //配送任务
            toActivity(DispatchTaskActivity.class);
        } else if (item.getNameCode().equals(Common.FUNC_PDLB)) {
            //盘点列表
            toActivity(CheckTaskActivity.class);
        } else if (item.getNameCode().equals(Common.FUNC_PDCY)) {
            //盘点差异
            toActivity(DifferReportActivity.class);
        } else if (item.getNameCode().equals(Common.FUNC_WENTJSB)) {
            //问题件上报
            toActivity(ProblemBillUploadActivity.class);
        } else if (item.getNameCode().equals(Common.FUNC_WUTJSB)) {
            //无头件上报
            toActivity(WithoutTitleBillActivity.class);
        } else if (item.getNameCode().equals(Common.FUNC_PSTD)) {
            //配送退单
            toActivity(DispatchBackScanActivity.class);
        } else if (item.getNameCode().equals(Common.FUNC_DDBD)) {
            //单独绑定
            toActivity(SingleUnBindActivity.class);
        } else if (item.getNameCode().equals(Common.FUNC_YDRK)) {
            //运单入库
            toActivity(StockInLocalDeptActivity.class);
        } else if (item.getNameCode().equals(Common.FUNC_CNFJ)) {
            //场内分拣
            toActivity(SortingActivity.class);
        } else if (item.getNameCode().equals(Common.FUNC_JXCSM)) {
            //旧卸车扫描
            if (sharedPreferUtil.getOfflineMode()) {
                ToastUtil.showToast(getString(R.string.no_use_in_offline));
                return;
            }
            toActivity(CreateUnloadTaskActivity.class);
        } else if (item.getNameCode().equals(Common.FUNC_LHSM)) {
            //揽货扫描
            toActivity(LanHuoScanActivity.class);
        } else if (item.getNameCode().equals(Common.FUNC_YCGL)) {
            //异常管理
            toActivity(ExceptionUploadActivity.class);
        } else if (item.getNameCode().equals(Common.FUNC_JBGL)) {
            //建包管理
            toActivity(CreatePackageMangerActivity.class);
        } else if (item.getNameCode().equals(Common.FUNC_YKDH)) {
            //移库倒货
            queryPlaceRequest();
        } else if (item.getNameCode().equals(Common.FUNC_QDGL)) {
            //签到管理
            toActivity(SelectBreakCardTypeActivity.class);
        } else if (item.getNameCode().equals(Common.FUNC_FBZT)) {
            //分拨自提
            goToFenBoZiTi();
        } else if (item.getNameCode().equals(Common.FUNC_KYDH)) {
            //同行卸车（跨越）
            toActivity(KuaYueTaskActivity.class);
        } else if (item.getNameCode().equals(Common.FUNC_CWSB)) {
            //仓位上报
            toActivity(FitActivity.class);
        } else if (item.getNameCode().equals(Common.FUNC_JBCZ)) {
//            //建包操作
//            toActivity(CreatePackageOperatorActivity.class);
        } else if (item.getNameCode().equals(Common.FUNC_JBCZV)) {
//            //解包操作
//            toActivity(ReleasePackageOperatorActivity.class);
        } else if (item.getNameCode().equals(Common.FUNC_AJSM)) {
            ScanOpenUtils.getInstance().enableScan(getContext());
            //安检扫描
            Intent intent = new Intent(getContext(), UIActivity.getUIClass("safecheck"));
            JSONObject json = new JSONObject();
            json.put("name", "safecheck");
            json.put("NAME", "安检扫描");
            json.put("taskNo", down_util.INSTANCE.get_task_no("safecheck"));
            json.put("hui", true);
            json.put("taskType", "PDA_SCAN_TYPE_STAY");
            intent.putExtra("data", json.toJSONString());
            startActivity(intent);
        } else if (item.getNameCode().equals(Common.FUNC_XJSM)) {
            ScanOpenUtils.getInstance().enableScan(getContext());
            //小件扫描
            Intent intent = new Intent(getContext(), ScanActivity.class);
            JSONObject json = new JSONObject();
            json.put("name", "smallclothes");
            json.put("NAME", "小件扫描");
            json.put("taskNo", down_util.INSTANCE.get_task_no("smallclothes"));
            json.put("hui", true);
            json.put("taskType", "PDA_SCAN_TYPE_SMALL_OBJECT");
            intent.putExtra("data", json.toJSONString());
            startActivity(intent);
        } else if (item.getNameCode().equals(Common.FUNC_HLJSM)) {
            ScanOpenUtils.getInstance().enableScan(getContext());
            //回流件扫描
            Intent intent = new Intent(getContext(), ScanBackFlowActivity.class);
            JSONObject json = new JSONObject();
            json.put("hui", true);
            json.put("NAME", "回流件扫描");
            json.put("name", "back_flow_scan");
            json.put("taskType", "PDA_SCAN_TYPE_REFLUX");
            intent.putExtra("data", json.toJSONString());
            startActivity(intent);
        } else if (item.getNameCode().equals(Common.FUNC_CCSB)) {
            ScanOpenUtils.getInstance().enableScan(getContext());
            //差错上报
            Intent intent = new Intent(getContext(), MisTakeTypeListActivity.class);
            startActivity(intent);
        } else if (item.getNameCode().equals(Common.FUNC_SJSM)) {
            ScanOpenUtils.getInstance().enableScan(getContext());
            //收件扫描
            Intent intent = new Intent(getContext(), PickupScanActivity.class);
            JSONObject json = new JSONObject();
            json.put("hui", true);
            json.put("name", "pickup_scan");
            json.put("NAME", "收件扫描");
            json.put("taskType", "PDA_SCAN_TYPE_GET");
            json.put("taskNo", down_util.INSTANCE.get_task_no("pickup_scan"));
            intent.putExtra("data", json.toJSONString());
            startActivity(intent);
        } else if (item.getNameCode().equals(Common.FUNC_RCSM)) {
            ScanOpenUtils.getInstance().enableScan(getContext());
            //入仓扫描
            Intent intent = new Intent(getContext(), WareHousingScanActivity.class);
            startActivity(intent);
        } else if (item.getNameCode().equals(Common.FUNC_SMZYS)) {
            ScanOpenUtils.getInstance().enableScan(getContext());
            //实名制验收
            Intent intent = new Intent(getContext(), RealNameRegistrationActivity.class);
            startActivity(intent);
        } else if (item.getNameCode().equals(Common.FUNC_JBSM)) {
            ScanOpenUtils.getInstance().enableScan(getContext());
            //建包扫描
            Intent intent = new Intent(getContext(), CenterJobActivity.class);
            intent.putExtra("code", "pack_scan");
            intent.putExtra("name", "建包扫描");
            startActivity(intent);
        } else if (item.getNameCode().equals(Common.FUNC_LJSM)) {
            ScanOpenUtils.getInstance().enableScan(getContext());
            //领件扫描
            Intent intent = new Intent(getContext(), CenterJobActivity.class);
            intent.putExtra("code", "wd_receive_scan");
            intent.putExtra("name", "领件扫描");
            startActivity(intent);
        } else if (item.getNameCode().equals(Common.FUNC_LCSM)) {
            ScanOpenUtils.getInstance().enableScan(getContext());
            //留仓扫描
            Intent intent = new Intent(getContext(), StoreHouseActivity.class);
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("name", "storehouse");
            jsonObject.put("NAME", "留仓件扫描");
            jsonObject.put("taskNo", down_util.INSTANCE.get_task_no("storehouse"));
            jsonObject.put("hui", true);
            jsonObject.put("taskType", "PDA_SCAN_TYPE_STAY");
            intent.putExtra("data", jsonObject.toJSONString());
            startActivity(intent);
        } else if (item.getNameCode().equals(Common.FUNC_HDDJSM)) {
            ScanOpenUtils.getInstance().enableScan(getContext());
            //回单到件扫描
            Intent intent = new Intent(getContext(), JobActivity.class);
            intent.putExtra("code", "receipt_reach");
            intent.putExtra("name", "回单到件");
            startActivity(intent);
        } else if (item.getNameCode().equals(Common.FUNC_HDFJSM)) {
            ScanOpenUtils.getInstance().enableScan(getContext());
            //回单发件扫描
            Intent intent = new Intent(getContext(), JobActivity.class);
            intent.putExtra("code", "receipt_send");
            intent.putExtra("name", "回单发件");
            startActivity(intent);
        } else if (item.getNameCode().equals(Common.FUNC_WDJJSM)) {
            ScanOpenUtils.getInstance().enableScan(getContext());
            //网点交接
            Intent intent = new Intent(getContext(), JobActivity.class);
            intent.putExtra("code", "wd_send_scan");
            intent.putExtra("isShowCardMark", false);
            intent.putExtra("name", "网点交接");
            startActivity(intent);
        } else if (item.getNameCode().equals(Common.FUNC_PJSM)) {
            ScanOpenUtils.getInstance().enableScan(getContext());
            //派件扫描
            Intent intent = new Intent(getContext(), DespatchScanActivity.class);
            startActivity(intent);
        } else if (item.getNameCode().equals(Common.FUNC_ZHDJSM)) {
            ScanOpenUtils.getInstance().enableScan(getContext());
            //找货登记
            Intent intent = new Intent(getContext(), LookingForActivity.class);
            startActivity(intent);
        } else if (item.getNameCode().equals(Common.FUNC_YJDD)) {
            //一键到达
            Intent intent = new Intent(getContext(), ArriveActivity.class);
            startActivity(intent);
        } else if (item.getNameCode().equals(Common.FUNC_SFSM)) {
            ScanOpenUtils.getInstance().enableScan(getContext());
            //收发扫描
            Intent intent = new Intent(getContext(), ScanReceiverToSendActivity.class);
            intent.putExtra("code", "dispatch");
            intent.putExtra("name", "收发扫描");
            startActivity(intent);
        } else if (item.getNameCode().equals(Common.FUNC_DPSM)) {
            ScanOpenUtils.getInstance().enableScan(getContext());
            //到派扫描
            Intent intent = new Intent(getContext(), ScanArriveToSendActivity.class);
            intent.putExtra("code", "reachsend_scan");
            intent.putExtra("name", "到派扫描");
            startActivity(intent);
        } else if (item.getNameCode().equals(Common.FUNC_JBASM)) {
            ScanOpenUtils.getInstance().enableScan(getContext());
            //解包扫描
            Intent intent = new Intent(getContext(), CenterJobActivity.class);
            intent.putExtra("code", "unpack_scan");
            intent.putExtra("name", "解包扫描");
            startActivity(intent);
        } else if (item.getNameCode().equals(Common.FUNC_HLJASM)) {
            ScanOpenUtils.getInstance().enableScan(getContext());
            //回流件
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("hui", true);
            jsonObject.put("NAME", "回流件扫描");
            jsonObject.put("name", "back_flow_scan");
            jsonObject.put("taskType", "PDA_SCAN_TYPE_REFLUX");
            Intent intent = new Intent(getContext(), ScanBackFlowActivity.class);
            intent.putExtra("data", jsonObject.toJSONString());
            startActivity(intent);
        } else if (item.getNameCode().equals(Common.FUNC_SJIANSM)) {
            ScanOpenUtils.getInstance().enableScan(getContext());
            //小件扫描
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("name", "smallclothes");
            jsonObject.put("NAME", "小件扫描");
            jsonObject.put("taskNo", down_util.INSTANCE.get_task_no("smallclothes"));
            jsonObject.put("hui", true);
            jsonObject.put("taskType", "PDA_SCAN_TYPE_SMALL_OBJECT");

            Intent intent = new Intent(getContext(), ScanActivity.class);
            intent.putExtra("data", jsonObject.toJSONString());
            startActivity(intent);
        } else if (item.getNameCode().equals(Common.FUNC_YJLC)) {
            ScanOpenUtils.getInstance().enableScan(getContext());
            //一键留仓
            Intent intent = new Intent(getContext(), OneKeyActivity.class);
            startActivity(intent);
        } else if (item.getNameCode().equals(Common.FUNC_AJIANSM)) {
            ScanOpenUtils.getInstance().enableScan(getContext());
            //安检扫描
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("name", "safecheck");
            jsonObject.put("NAME", "安检扫描");
            jsonObject.put("taskNo", down_util.INSTANCE.get_task_no("safecheck"));
            jsonObject.put("hui", true);
            jsonObject.put("taskType", "PDA_SCAN_TYPE_STAY");
            Intent intent = new Intent(getContext(), SafeCheckActivity.class);
            intent.putExtra("data", jsonObject.toJSONString());
            startActivity(intent);
        } else if (item.getNameCode().equals(Common.FUNC_XXFSM)) {
            ScanOpenUtils.getInstance().enableScan(getContext());
            //小信封扫描
            Intent intent = new Intent(getContext(), ScanMailerActivity.class);
            intent.putExtra("name", "小信封扫描");
            startActivity(intent);
        } else if (item.getNameCode().equals(Common.FUNC_TJSM)) {
            ScanOpenUtils.getInstance().enableScan(getContext());
            //退件扫描
            Intent intent = new Intent(getContext(), RetreatItemScanActivity.class);
            startActivity(intent);
        } else if (item.getNameCode().equals(Common.FUNC_CWEISB)) {
            ScanOpenUtils.getInstance().enableScan(getContext());
            //仓位上报
            Intent intent = new Intent(getContext(), FitActivity.class);
            startActivity(intent);
        }
        else if (item.getNameCode().equals(Common.FUNC_LCFJ)) {
            ScanOpenUtils.getInstance().enableScan(getContext());
            //留仓发件
            Intent intent = new Intent(getContext(), StockSendActivity.class);
            startActivity(intent);
        }
        else if (item.getNameCode().equals(Common.FUNC_CCCX)) {
            //差错查询
            Intent intent = new Intent(getContext(), MisTakeQueryActivity.class);
            startActivity(intent);
        } else if (item.getNameCode().equals(Common.FUNC_KJGZ)) {
            ScanOpenUtils.getInstance().enableScan(getContext());
            //快件跟踪
            Intent billSearch = new Intent(getContext(), ExpressMailTrailActivity.class);
            startActivity(billSearch);
        } else if (item.getNameCode().equals(Common.FUNC_FCSM)) {
            ScanOpenUtils.getInstance().enableScan(getContext());
            //复称扫描
            Intent intent = new Intent(getContext(), CenterJobActivity.class);
            intent.putExtra("code", "fucheng");
            intent.putExtra("name", "复称扫描");
            startActivity(intent);
        } else if (item.getNameCode().equals(Common.FUNC_SCTJ)) {
            //上传统计
            String array = "[" +
                    "{\"menuCode\":\"fucheng\",\"menuName\":\"复称扫描\",\"menuType\":\"1\"}," +
                    "{\"menuCode\":\"back_flow_scan\",\"menuName\":\"回流件\",\"menuType\":\"1\"}," +
                    "{\"menuCode\":\"smallclothes\",\"menuName\":\"小件扫描\",\"menuType\":\"1\"}," +
                    "{\"menuCode\":\"stocksend\",\"menuName\":\"留仓发件\",\"menuType\":\"1\"}," +
                    "{\"menuCode\":\"onekey\",\"menuName\":\"\",\"menuType\":\"1\"}," +
                    "{\"menuCode\":\"safecheck\",\"menuName\":\"安检扫描\",\"menuType\":\"1\"}," +
                    "{\"menuCode\":\"mailer_scan\",\"menuName\":\"小信封扫描\",\"menuType\":\"1\"}," +
                    "{\"menuCode\":\"retreat_item\",\"menuName\":\"退件扫描\",\"menuType\":\"1\"}," +
                    "{\"menuCode\":\"receipt_reach\",\"menuName\":\"回单到件\",\"menuType\":\"1\"}," +
                    "{\"menuCode\":\"receipt_send\",\"menuName\":\"回单发件\",\"menuType\":\"1\"}," +
                    "{\"menuCode\":\"pack_scan\",\"menuName\":\"建包扫描\",\"menuType\":\"1\"}," +
                    "{\"menuCode\":\"problem\",\"menuName\":\"问题件\",\"menuType\":\"1\"}," +
                    "{\"menuCode\":\"unpack_scan\",\"menuName\":\"解包扫描\",\"menuType\":\"1\"}," +
                    "{\"menuCode\":\"instore_scan\",\"menuName\":\"入仓扫描\",\"menuType\":\"1\"}," +
                    "{\"menuCode\":\"pickup_scan\",\"menuName\":\"收件扫描\",\"menuType\":\"1\"}," +
                    "{\"menuCode\":\"wd_receive_scan\",\"menuName\":\"领件扫描\",\"menuType\":\"1\"}," +
                    "{\"menuCode\":\"storehouse\",\"menuName\":\"留仓扫描\",\"menuType\":\"1\"}," +
                    "{\"menuCode\":\"wd_send_scan\",\"menuName\":\"网点发件\",\"menuType\":\"1\"}," +
                    "{\"menuCode\":\"wd_send_scan\",\"menuName\":\"网点交接\",\"menuType\":\"1\"}," +
                    "{\"menuCode\":\"dispatch_scan\",\"menuName\":\"派件扫描\",\"menuType\":\"1\"}," +
                    "{\"menuCode\":\"dispatch\",\"menuName\":\"收发扫描\",\"menuType\":\"1\"}," +
                    "{\"menuCode\":\"reachsend_scan\",\"menuName\":\"到派扫描\",\"menuType\":\"1\"}," +
                    "{\"menuCode\":\"wd_reach_scan\",\"menuName\":\"网点到件\",\"menuType\":\"1\"}," +
                    "  ]";
            Intent intent = new Intent(getContext(), UploadStatisticsActivity.class);
            intent.putExtra("data", String.format(array));
            startActivity(intent);
        }

    }


    /**
     * 跳转至分拨自提
     */
    protected void goToFenBoZiTi() {
        Intent intent = null;
        int deptType = sharedPreferUtil.getIntValue(Common.DEPT_TYPE);
        if (deptType == 5 || deptType == 6) {
            //判断是否是分拨,跳转至装卸组
            intent = new Intent(getContext(), LoadUnloadGroupActivity.class);
        } else {
            intent = new Intent(getContext(), FenBoZiTiActivity.class);
        }
        //扫描类型：1-装车扫描，2=卸车扫描 ,3-离线装车，4-离线卸车,5-移库装车，6-移库卸车，7-单独移库卸车,8-分拨自提
        intent.putExtra("scanType", 8);
        startActivity(intent);
    }

    /**
     * 查询场地
     */
    protected void queryPlaceRequest() {
        LoadUtils.showLoading("请求数据中...", getContext());
        final QueryPlaceNetRequest placeNetRequest = new QueryPlaceNetRequest().setDeptCode(sharedPreferUtil.getDeptCode());
        //查询该部门是否启用移库倒货功能
        placeNetRequest.queryDataDict(new UICallBack() {
            @Override
            public void onError(String msg) {
                LoadUtils.hideLoading(getContext());
                if (msg != null) {
                    ToastUtil.showToast(msg);
                }
            }

            @Override
            public void onSuccess(Object obj) {
                //启用移库倒货功能，则查询场地
                placeNetRequest.querySpaceByDept(new UICallBack() {
                    @Override
                    public void onError(String msg) {
                        LoadUtils.hideLoading(getContext());
                        if (msg != null) {
                            ToastUtil.showToast(msg);
                        }
                    }

                    @Override
                    public void onSuccess(Object obj) {
                        LoadUtils.hideLoading(getContext());
                        List<CurrentSpaceEntity> dataList = (List<CurrentSpaceEntity>) obj;
                        placeNetRequest.showSelectSpaceDialog(getContext(), dataList, new OnClickCallBack() {
                            @Override
                            public void onCancle() {
                            }

                            @Override
                            public void onSure(Object obj, Object dialog) {
                                CurrentSpaceEntity currentSpaceEntity = (CurrentSpaceEntity) obj;
                                if (currentSpaceEntity != null && currentSpaceEntity.isCheck()) {
                                    LoadUtils.hideLoading(getContext());
                                    Dialog mDialog = (Dialog) dialog;
                                    mDialog.dismiss();
                                    //保存当前所在场地
                                    sharedPreferUtil.setValue(Common.PLACE_CODE, currentSpaceEntity.getPlaceCode());
                                    sharedPreferUtil.setValue(Common.PLACE_NAME, currentSpaceEntity.getPlaceName());
                                    toActivity(MoveStockActivity.class);
                                } else {
                                    ToastUtil.showToast("请选择当前所在场地！");
                                }
                            }
                        });
                    }
                });
            }
        });
    }
}
